package com.ghsc.ghxc.jsb.ui.live

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.live.bean.VideoResultDataBean
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.live
 * 类名：TabLiveVideoViewModel
 * 创建时间：2024/5/10 10:17
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class TabLiveVideoViewModel : BaseViewModel() {


    val onSelectedVideoData: MutableLiveData<BaseResponse<VideoResultDataBean>> = MutableLiveData()
    fun onSelectedVideoMethod(paras: String) {
        launch {
            val response =
                withContext(Dispatchers.IO) { ApiMarket.service.onSelectedVideoData(paras) }
            executeResponse(
                response,
                { onSelectedVideoData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }

    /**  权限  **/
    val onGetzhiboAuthData: MutableLiveData<Any> = MutableLiveData()
    fun onGetzhiboAuthMethod(paras: String) {
        launch {
            val response =
                withContext(Dispatchers.IO) { ApiMarket.service.onGetzhiboAuthData(paras) }
            executeResponse(
                response,
                { onGetzhiboAuthData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }
}